import twitter4j.Status;
import twitter4j.Twitter;
import twitter4j.TwitterFactory;
import twitter4j.auth.AccessToken;
import twitter4j.conf.*;

import java.io.IOException;

public final class UpdateStatus {

public static void main(String[] args) throws IOException {

String testPost = "hello from otc";
String consumerKey = "mVxvwr201bMzJqp1CRT9A";
String consumerSecret = "mPyS0fbeY5MdsSiFAdwY0U6JMaNemmRpc9aIALux4Wg";
String accessToken = "2192884596-iBu3FFgigz97vWGJZRt8YXT8fJ1CCaX5gozzkH6";
String accessSecret = "ACjjMvsR5jvsdEmxf17ZNH9YTFjbwD9MM7KejYp6TR9gQ";

// ConfigurationBuilder cb = new ConfigurationBuilder();
//
// cb.setDebugEnabled(true)
// .setOAuthConsumerKey(consumerKey)
// .setOAuthConsumerSecret(consumerSecret)
// .setOAuthAccessToken(accessToken)
// .setOAuthAccessTokenSecret(accessSecret);

try {
TwitterFactory factory = new TwitterFactory();
Twitter twitter = factory.getInstance();
AccessToken accestoken = new AccessToken(accessToken, accessSecret);

// twitter.setOAuthConsumer(consumerKey, consumerSecret);
twitter.setOAuthAccessToken(accestoken);
Status status = twitter.updateStatus(testPost);
System.out.println("it worked!");
if (status.getId() == 0) {
System.out
.println("Error occured while posting tweets to twitter");
}
} catch (Exception e) {
e.printStackTrace();
}
}
}
